﻿#ifndef SQLITE_H
#define SQLITE_H

#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>
#include <QList>
struct User{
    QString name;//账号
    QString pswd;//密码
};


class Sqlite : public QObject
{
    Q_OBJECT
public:
    explicit Sqlite(QObject *parent = nullptr);
    static Sqlite *ptrSql;
    static Sqlite *getIntance(){
        if(nullptr == ptrSql){
            ptrSql = new Sqlite;
            return ptrSql;
        }
    }
public:
    void init(); //数据库初始化

    bool addUser(User info);//添加用户

    QList<User> getAllUser();//获取所以用户

    bool isExist(QString name);//判断用户是否存在

signals:

private:
    QSqlDatabase db;

};

#endif // SQLITE_H
